#include <stdio.h>

int main()
{
	int n = 0, k = 0, m = 0;
	scanf("%d %d", &n, &k);
	for ( int i = 0; i < n; i++ ) 
	{
		scanf("%d", &m);
		int cnt = 0;
		while ( m > 0 ) 
		{
			if ( m % 10 == 3 ) {
				cnt ++;
			}
			m /= 10;
		}
		if ( cnt == k ) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	return 0;
} 
